{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from selenium import webdriver"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "url = 'http://www.jianshu.com/p/c9bae3e9e252'\n",
    "def get_info(url):\n",
    "    include_title =[]\n",
    "    driver = webdriver.Chrome()\n",
    "    driver.get(url)\n",
    "    driver.implicitly_wait(20)\n",
    "    author = driver.find_element_by_xpath('//span[@class=\"name\"]/a').text\n",
    "    date = driver.find_element_by_xpath('//span[@class=\"publish-time\"]').text\n",
    "    word = driver.find_element_by_xpath('//span[@class=\"wordage\"]').text\n",
    "    view = driver.find_element_by_xpath('//span[@class=\"views-count\"]').text\n",
    "    comment = driver.find_element_by_xpath('//span[@class=\"comments-count\"]').text\n",
    "    like = driver.find_element_by_xpath('//span[@class=\"likes-count\"]').text\n",
    "    included_names = driver.find_elements_by_xpath('//div[@class=\"include-collection\"]/a/div')\n",
    "    for i in included_names:\n",
    "        include_title.append(i.text)\n",
    "    print(author,date,word,view,comment,like,include_title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "韩大爷的杂货铺 2017.03.01 11:26* 字数 2529 阅读 6599 评论 54 喜欢 234 ['杂文 人生感悟', '谈写作', '想法', '首页投稿（暂停...', '今日看点', '写作', '五星']\n"
     ]
    }
   ],
   "source": [
    "get_info(url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
